<?php

namespace app\api\controller;

use app\common\exception\BusinessException;
use think\response\Json;

class AppConfig extends Base
{
    /**
     * 获取配置
     * @throws
     */
    public function get(): Json
    {
        // 请求参数
        $params = $this->request->param();

        //验证规则
        $rule = [
            'config_type' => 'require',
        ];

        // 错误信息
        $errMsg = [
            'config_type.require' => '配置类型不得为空',
        ];

        // 数据验证
        $valRel = $this->validate($params, $rule, $errMsg);
        if ($valRel !== true) {
            throw new BusinessException($valRel, 0);
        }

        // 查询数据
        $list = app(\app\api\logic\AppConfig::class)->get($params);

        //返回数据
        return $this->response($list);
    }
}
